package cn.itcast.controller;

import cn.itcast.domain.Archive;
import cn.itcast.service.ArchiveService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @Author： ~Mr·Weng~
 * @CreateTime： 2019年-04月-21日  3:58
 * Look at the wine in the glass toast the rich first.
 */
@Controller
public class ArchiveController {


    private ArchiveService archiveService;
    @Autowired
    public void setArchiveService(ArchiveService archiveService) {
        this.archiveService = archiveService;
    }

    @RequestMapping("/archive_pageQuery")
    @ResponseBody
    public Map archive_pageQuery(int page , int rows){
        Page<Archive> archivePage ;
        Map<String, Object> map = new HashMap<>();
        try {
            archivePage = archiveService.pageQuery(page, rows);
            map.put("total",archivePage.getTotalElements());
            map.put("rows",archivePage.getContent());
        } catch (Exception e) {
            e.printStackTrace();
            return new HashMap();
        }
        return map;
    }
}
